﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RBOSS.Data;
using RBOSS.Business.CustomerModule;


namespace RBOSS.Business.VendorModule
{
    public class vendorShippingorders
    {
        RBOSSEntities rb = new RBOSSEntities();
        public int ProductId { get; set; }
        public int UserId { get; set; }
        public string ProductName { get; set; }
        public string Image { get; set; }
        public int Quantity { get; set; }
        public int ShippingId { get; set; }
        public int OrderId { get; set; }
        public int StatusId { get; set; }
        public string ShipTo { get; set; }
        public string ShipAddress1 { get; set; }
        public string ShipCity { get; set; }
        public string ShipProvience { get; set; }
        public string SipPostalCode { get; set; }
        public System.DateTime OrderDate { get; set; }

        public List<vendorShippingorders> getshippment(string email)
        {
            CustomerSubSystem s = new CustomerSubSystem();
            int userid = s.GetCustomerId(email);
            List<vendorShippingorders> lstshippmentorder = new List<vendorShippingorders>();
            var quary = from ship in rb.Shippings
                        join or in rb.Orders
                        on ship.OrderId equals or.OrderId
                        join ord in rb.OrderDetails
                        on ship.OrderId equals ord.OrderId
                        join pro in rb.Products
                        on ord.ProductId equals pro.ProductId
                        where pro.UserId == userid
                        select new vendorShippingorders 
                        { ProductId = pro.ProductId, UserId = pro.UserId, 
                          ProductName = pro.ProductName, Image = pro.Image, Quantity = ord.Quantity,
                          OrderId = ord.OrderId,
                          StatusId = ship.StatusId,
                          ShipTo=ship.ShipTo,
                          ShipAddress1 = ship.ShipAddress1,
                          ShipCity=ship.ShipCity,
                          ShipProvience=ship.ShipProvince,
                          SipPostalCode=ship.ShipPostalCode,
                          OrderDate=or.OrderDate,
                        };
            foreach (vendorShippingorders item in quary)
            {
                lstshippmentorder.Add(item);
            }
            return lstshippmentorder;
        }
    }
}
